package com.springboot.demo.entity;

import com.springboot.demo.entity.validate.SceneIdGroup;
import com.springboot.demo.entity.validate.user.IdGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

/**
 * @author wubc683
 * @desc
 * @date 2021-10-13 11:51
 */
@Data
@ApiModel(description = "变量数不超过500")
public class Variable {
    @ApiModelProperty(value = "变量id", required = true)
    @NotNull(message = "变量id不能为null", groups = IdGroup.class)
    private Long id;
    @ApiModelProperty(value = "变量序号", required = true)
    @NotNull(message = "变量序号不能为null")
    @Min(value = 0, message = "变量序号最小值为0")
    @Max(value = 50000, message = "变量序号最大值为50000")
    private Integer varNo;
    @ApiModelProperty(value = "变量名称",required = true)
    @NotBlank(message = "变量名称不能为null或者空")
    @Length(max = 32,message = "变量名长度错误")
    @Pattern(regexp = "^[\\u4E00-\\u9FA5a-zA-Z0-9_-]{1,32}$", message = "变量名格式错误")
    private String name;
//    @ApiModelProperty(value = "连接名称", required = true)
//    @NotBlank(message = "连接名称不能为null或者空")
//    @Length(max = 32, message = "连接名称太长")
//    private String connectName;
    @ApiModelProperty(value = "连接序号", required = true)
    @NotNull(message = "连接序号不能为null")
    private Integer connectNo;
    @ApiModelProperty(value = "场景id", required = true)
    @NotNull(message = "场景id不能为null",groups = SceneIdGroup.class)
    private Long sceneId;
    @ApiModelProperty(value = "数据类型,值对应类型参考开发说明文档", required = true)
    @NotNull(message = "数据类型不能为null")
    private Integer dataType;
    @ApiModelProperty(value = "长度", required = true)
    @NotNull(message = "变量长度不能为null")
    private Integer len;
    @ApiModelProperty(value = "地址", required = true)
    @NotNull(message = "变量地址不能为null或者空")
    @Length(max = 16, message = "变量地址太长")
    private String varAddr;
    @ApiModelProperty(value = "采集周期，单位秒(最大周期值3600s),默认1秒")
    @NotNull(message = "采集周期不能为null")
    private Integer cycleTime = 1000;
    @ApiModelProperty("变量所在的区域")
    private Integer area;
    @ApiModelProperty("子区域300协议 DB用到")
    private Integer subArea;
    @ApiModelProperty("数据在PLC中的地址偏移量")
    private Integer addOffset;
    @ApiModelProperty("如果需要位偏移量，那么这个位变量的偏移量，否则写-1")
    private Integer bitOffset;
}
